<?php

namespace app\admin\controller\supplier;

use app\admin\controller\Controller;
use app\admin\model\supplier\Mobile as MobileModel;
use app\admin\validate\supplier\Mobile as MobileValidate;

class Mobile extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 列表
     */
    public function list()
    {
        $model = new MobileModel;
        $data = input('post.');
        return $model->getList($data);
    }

    /**
     * 添加
     */
    public function create()
    {
        $data = input('post.');
        $validate = new MobileValidate;
        if (!$validate->scene('create')->check($data)) {
            return fail($validate->getError());
        }

        $model = new MobileModel;
        return $model->create($data);
    }

    /**
     * 编辑
     */
    public function edit()
    {
        $data = input('post.');
        $validate = new MobileValidate;
        if (!$validate->scene('edit')->check($data)) {
            return fail($validate->getError());
        }

        $model = new MobileModel;
        return $model->edit($data);
    }

    /**
     * 账户余额
     */
    public function balance()
    {
        $model = new MobileModel;
        return $model->getBalance(input('post.id'));
    }

    /**
     * 删除
     */
    public function delete()
    {
        $data = input('post.');
        $model = new MobileModel;
        return $model->delete($data);
    }

    /**
     * 代理商关联列表
     */
    public function agentList()
    {
        $model = new MobileModel;
        $data = input('post.');
        return $model->getAgentList($data);
    }

    /**
     * 关联/取消关联代理商
     */
    public function associationAgent()
    {
        $model = new MobileModel;
        $data = input('post.');
        return $model->associationAgent($data);
    }

    /**
     * 每日余额快照
     */
    public function dailyBalanceLog()
    {
        $params = input('post.');
        $model = new \app\admin\model\supplier\Mobile;
        return $model->getDailyBalanceList($params);
    }
}
